// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio;

import fmod.fmod.FMOD_STUDIO_EVENT_DESCRIPTION;
import fmod.fmod.FMOD_STUDIO_PARAMETER_DESCRIPTION;
import zombie.core.Core;

public final class GameSoundClip {
    public static short INIT_FLAG_DISTANCE_MIN = 1;
    public static short INIT_FLAG_DISTANCE_MAX = 2;
    public final GameSound gameSound;
    public String event;
    public FMOD_STUDIO_EVENT_DESCRIPTION eventDescription;
    public FMOD_STUDIO_EVENT_DESCRIPTION eventDescriptionMP;
    public String file;
    public float volume = 1.0F;
    public float pitch = 1.0F;
    public float distanceMin = 10.0F;
    public float distanceMax = 10.0F;
    public float reverbMaxRange = 10.0F;
    public float reverbFactor = 0.0F;
    public int priority = 5;
    public short initFlags = 0;
    public short reloadEpoch;

    public GameSoundClip(GameSound _gameSound) {
        this.gameSound = _gameSound;
        this.reloadEpoch = _gameSound.reloadEpoch;
    }

    public String getEvent() {
        return this.event;
    }

    public String getFile() {
        return this.file;
    }

    public float getVolume() {
        return this.volume;
    }

    public float getPitch() {
        return this.pitch;
    }

    public boolean hasMinDistance() {
        return (this.initFlags & INIT_FLAG_DISTANCE_MIN) != 0;
    }

    public boolean hasMaxDistance() {
        return (this.initFlags & INIT_FLAG_DISTANCE_MAX) != 0;
    }

    public float getMinDistance() {
        return this.distanceMin;
    }

    public float getMaxDistance() {
        return this.distanceMax;
    }

    public float getEffectiveVolume() {
        float _float = 1.0F;
        switch (this.gameSound.master) {
            case Primary:
                _float = zombie.SoundManager.instance.getSoundVolume();
                break;
            case Ambient:
                _float = zombie.SoundManager.instance.getAmbientVolume();
                break;
            case Music:
                _float = zombie.SoundManager.instance.getMusicVolume();
                break;
            case VehicleEngine:
                _float = zombie.SoundManager.instance.getVehicleEngineVolume();
        }

        _float *= this.volume;
        return _float * this.gameSound.getUserVolume();
    }

    public float getEffectiveVolumeInMenu() {
        float _float = 1.0F;
        switch (this.gameSound.master) {
            case Primary:
                _float = (float)Core.getInstance().getOptionSoundVolume() / 10.0F;
                break;
            case Ambient:
                _float = (float)Core.getInstance().getOptionAmbientVolume() / 10.0F;
                break;
            case Music:
                _float = (float)Core.getInstance().getOptionMusicVolume() / 10.0F;
                break;
            case VehicleEngine:
                _float = (float)Core.getInstance().getOptionVehicleEngineVolume() / 10.0F;
        }

        _float *= this.volume;
        return _float * this.gameSound.getUserVolume();
    }

    public GameSoundClip checkReloaded() {
        if (this.reloadEpoch == this.gameSound.reloadEpoch) {
            return this;
        } else {
            GameSoundClip gameSoundClip1 = null;

            for (int _int = 0; _int < this.gameSound.clips.size(); _int++) {
                GameSoundClip gameSoundClip2 = (GameSoundClip)this.gameSound.clips.get(_int);
                if (gameSoundClip2 == this) {
                    return this;
                }

                if (gameSoundClip2.event != null && gameSoundClip2.event.equals(this.event)) {
                    gameSoundClip1 = gameSoundClip2;
                }

                if (gameSoundClip2.file != null && gameSoundClip2.file.equals(this.file)) {
                    gameSoundClip1 = gameSoundClip2;
                }
            }

            if (gameSoundClip1 == null) {
                this.reloadEpoch = this.gameSound.reloadEpoch;
                return this;
            } else {
                return gameSoundClip1;
            }
        }
    }

    public boolean hasSustainPoints() {
        return this.eventDescription != null && this.eventDescription.bHasSustainPoints;
    }

    public boolean hasParameter(FMOD_STUDIO_PARAMETER_DESCRIPTION fMOD_STUDIO_PARAMETER_DESCRIPTION) {
        return this.eventDescription != null && this.eventDescription.hasParameter(fMOD_STUDIO_PARAMETER_DESCRIPTION);
    }
}
